<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-3.5.1.min.js"></script>
  </head>
  <body>
    <!DOCTYPE html>
    <html>
      <head>
        <meta charset="UTF-8" />
        <title>全选</title>
        <script>
          $(function () {
            //全选复选框的单击事件
            $('#all').click(function () {
              let checked = $('#all').prop('checked');
              let one = $('input[name="one"]');
              for (let i = 0; i < one.length; i++) {
                $(one[i]).prop('checked', checked);
              }
            });
            // 单选按钮添加点击事件
            $('[name="one"]').click(function () {
              let one = $('input[name="one"]');
              let all = $('input[id="all"]');
              for (let i = 0; i < one.length; i++) {
                if ($(one[i]).prop('checked') == false) {
                  all.prop('checked', false);
                  return;
                }
              }
              all.prop('checked', true);
            });
          });
        </script>
      </head>
      <body>
        <table id="myTable" border="1" cellpadding="0" cellspacing="0" width="90%" height="160px">
          <tr>
            <th>全选<input id="all" type="checkbox" /></th>
            <th>序号</th>
            <th>名称</th>
            <th>单价</th>
            <th>数量</th>
            <th>总计</th>
          </tr>
          <tr>
            <td><input name="one" type="checkbox" /></td>
            <td>1</td>
            <td>小熊饼干1</td>
            <td>￥125</td>
            <td>1</td>
            <td>￥125</td>
          </tr>
          <tr>
            <td><input name="one" type="checkbox" /></td>
            <td>2</td>
            <td>小熊饼干2</td>
            <td>￥125</td>
            <td>1</td>
            <td>￥125</td>
          </tr>
          <tr>
            <td><input name="one" type="checkbox" /></td>
            <td>3</td>
            <td>小熊饼干3</td>
            <td>￥125</td>
            <td>1</td>
            <td>￥125</td>
          </tr>
        </table>
      </body>
    </html>
  </body>
</html>
